<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateActivityGoods extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('activity_goods',['id'=>false,'comment'=>'招商活动商品表','collation'=>'utf8mb4_general_ci']);
        $table->addColumn('id','biginteger',['limit'=>20,'identity'=>true,'signed'=>false])
            ->setPrimaryKey('id')
            ->addColumn('buyin_activity_id','biginteger',['limit'=>20,'comment'=>'巨量百应活动id','signed'=>false])
            ->addColumn('apply_id','biginteger',['limit'=>20,'comment'=>'申请id','signed'=>false])
            ->addColumn('product_id','string',['limit'=>32,'comment'=>'商品id','signed'=>false])
            ->addColumn('product_promotion_id','biginteger',['limit'=>20,'comment'=>'商品推广id','signed'=>false])
            ->addColumn('product_name','string',['limit'=>80,'comment'=>'商品标题'])
            ->addColumn('product_price','biginteger',['comment'=>'售价(分)','signed'=>false])
            ->addColumn('product_img','string',['limit'=>255,'comment'=>'主图','default'=>''])
            ->addColumn('product_stock','biginteger',['limit'=>20,'comment'=>'商品库存','signed'=>false])
            ->addColumn('shop_name','string',['limit'=>80,'comment'=>'店铺名称'])
            ->addColumn('shop_id','biginteger',['limit'=>20,'comment'=>'店铺id','signed'=>false])
            ->addColumn('dsr','decimal',['precision'=>5,'scale'=>2,'comment'=>'店铺dsr','signed'=>false])
            ->addColumn('shop_phone','string',['limit'=>11,'comment'=>'店铺手机号','default'=>''])
            ->addColumn('is_new','boolean',['limit'=>1,'comment'=>'是否新店','default'=>1,'signed'=>false])
            ->addColumn('commission_effect_start_time','date',['comment'=>'佣金生效开始时间'])
            ->addColumn('commission_effect_end_time','date',['comment'=>'佣金生效结束时间'])
            ->addColumn('commission_rate','decimal',['precision'=>6,'scale'=>2,'comment'=>'团长佣金比例','signed'=>false])
            ->addColumn('common_commission_rate','decimal',['precision'=>6,'scale'=>2,'comment'=>'普通佣金比例','signed'=>false])
            ->addColumn('service_rate','decimal',['precision'=>5,'scale'=>2,'comment'=>'服务费率','signed'=>false])
            ->addColumn('promotion_url','string',['limit'=>255,'comment'=>'推广链接','default'=>''])
            ->addColumn('promotion_price','decimal',['precision'=>10,'scale'=>2,'comment'=>'可提供活动价','signed'=>false])
            ->addColumn('promotion_stock','biginteger',['limit'=>20,'comment'=>'可提供库存','signed'=>false])
            ->addColumn('gift_info','string',['limit'=>20,'comment'=>'赠品信息','default'=>''])
            ->addColumn('promotion_step','string',['limit'=>20,'comment'=>'活动价实现方式','default'=>''])
            ->addColumn('audit_status','boolean',['limit'=>1,'comment'=>'审核状态0待审核 1审核通过 2审核拒绝','default'=>0])
            ->addColumn('mini_show','boolean',['limit'=>1,'default'=>0,'comment'=>'是否显示在小程序 1 0'])
            ->addIndex('apply_id',['unique'=>true])
            ->addColumn('create_time','datetime',['comment'=>'创建时间'])
            ->addColumn('update_time','datetime',['comment'=>'更新时间'])
            ->create();
    }
}
